<template>
    <div :style="{display: show ? 'block' : 'none'}" class="dialog">
        <div class="content">
            <div class="title">
                <h3>{{ title }}</h3>
                <span @click="emit('close')">X</span>
            </div>
            <div class="con">
                <!-- 插槽 -->
                <slot></slot> 
                <p>{{ desc }}</p>
            </div>
            <div class="btns">
                <button class="no" @click="emit('close')">取消</button>
                <button class="ok" @click="emit('ok')">确认</button>
            </div>
        </div>
    </div>
</template>

<script setup>
    import {defineProps} from 'vue'

    const props = defineProps(['show', 'title', 'desc'])
    const emit = defineEmits(['close', 'ok'])
</script>

<style lang="scss" scoped>
    .dialog{
        position: fixed;
        left: 0;
        top: 0;
        width: 100vw;
        height: 100vh;
        background-color: rgba(0, 0, 0, .4);

        .content{
            position: fixed;
            left: 50%;
            top: 30%;
            min-width: 500px;
            min-height: 150px;
            background-color: #fff;
            transform: translate(-50%, -50%);
            border-radius: 10px;
            padding: 10px;
            display: flex;
            flex-direction: column;

            .title{
                display: flex;
                justify-content: space-between;
                align-items: center;
            }

            .con{
                flex: 1;
            }
            .btns{
                text-align: right;
                
                button{
                    margin: 0 10px;
                }
                .no{
                    background-color: #fff;
                    width: 80px;
                    height: 30px;
                    border: 1px solid #ccc;
                }
                .ok{
                    background-color: aqua;
                    width: 80px;
                    height: 30px;
                    border: none;
                }
            }
        }
    }
</style>